package javaapplication1;
import java.io.Console;
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Console cons = System.console();
Scanner input = new Scanner(System.in);

int ball[] = new int[10];
String name[] = new String[10];
int i = 0;
while (true) {
String n = input.next();
if (n.equals("."))break;
int b = input.nextInt();
boolean f = false;
for (int j = 0; j < i; j++)if (name[j].equals(n)) {
ball[j] += b;
f = true;
break;
}
if (f)continue;
name[i] = n;
ball[i] = b;
i++;
}
for (int j = 0; j < i; j++) System.out.println(name[j] + " " + ball[j]);
}
}